﻿@using MrCMS.Helpers
@using MrCMS.Web.Areas.Admin.Models
@model MrCMS.Web.Areas.Admin.Models.MergeWebpageModel
@{
    var confirmationModel = ViewData["confirmation-model"] as MergeWebpageConfirmationModel;
}
@using (Html.BeginForm("Confirm", "MergeWebpage", new { id = "" }, FormMethod.Post, new { }))
{
    <fieldset>
        <legend>
            @Resource("Admin Webpage Merge", "Merge")
        </legend>

        @Html.HiddenFor(x => x.Id)
        @Html.HiddenFor(x => x.MergeIntoId)
        @Html.HiddenFor(x => x.UpdateUrls)

        <p>
            @string.Format(Resource("Admin Webpage Merge - Confirm Text", "{0} record(s) will be impacted. Are you sure you would like to proceed?  This process will be added to a batch, it will not process immediately but may take several minutes to complete."), confirmationModel.ChangedPages.Count)
        </p>
        <div class="alert alert-warning">
            @Resource("Admin Webpage Merge - Confirm Structure Warning","This is a structural change, please confirm with your system administrator that a backup has been taken before proceeding")
        </div>

        <table class="table table-condensed table-striped">
            <thead>
                <tr>
                    <th>
                        @Resource("Old location")
                    </th>
                    <th>
                        @Resource("Old URL")
                    </th>
                    <th>
                        @Resource("New location")
                    </th>
                    <th>
                        @Resource("New URL")
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in confirmationModel.ChangedPages)
                {
                    <tr>
                        <td>@item.OldHierarchy</td>
                        <td>@item.OldUrl</td>
                        <td>@item.NewHierarchy</td>
                        <td>@item.NewUrl</td>
                    </tr>
                }
            </tbody>
        </table>
        <hr />
        <div class="btn-group">
            <button type="submit" class="btn btn-primary">@Resource("Complete")</button>
            @Html.ActionLink(Resource("Cancel"), "Edit", "Webpage", new { Model.Id }, new { @class = "btn btn-default" })
        </div>
    </fieldset>
}
@{
    Html.IncludeCss("~/Areas/Admin/Content/Scripts/lib/select2-3.4.5/select2.css");
    Html.IncludeScript("~/Areas/Admin/Content/Scripts/lib/select2-3.4.5/select2.min.js");
    Html.IncludeScript("~/Areas/Admin/Content/Scripts/mrcms/move-webpage.js");
}
